home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Language/OS - Multiplatform Resource Library
/
LANGUAGE OS.iso
/
smaltalk
/
st80_pr4.lha
/
st80_pre4
/
Foible
/
fsm
/
fsm-foible.st
Wrap
Text File
|
1993-07-24
|
27KB
|
1,169 lines
'Finite state machine simulator written as a class project
using Foible for CS497 REJ, fall 1990, by
Kamal A. Khan <kkhan@suna0.cs.uiuc.edu>'!
BoxWithPorts subclass: #FacsBox
instanceVariableNames: 'permanentForm value active '
classVariableNames: 'SmallTextStyle '
poolDictionaries: ''
category: 'Facs'!
!FacsBox methodsFor: 'form access'!
addInput: aValue toForm: aForm
"display aValue on aForm and return it"
self subclassResponsibility!
baseForm
"Return a copy of the Form representing the receiver"
^permanentForm deepCopy!
createForms
"This is the method that creates the form."
| aForm |
aForm _ self baseForm.
aForm offset: 0@0.
forms add: aForm!
inputForm
"return a copy of the receiver's form with the current input
displayed "
self subclassResponsibility!
inputForm: aValue
"return a copy of the receiver's form with aValue
displayed on it"
self subclassResponsibility!
permanentForm: aForm
"set the permanent form of the receiver to be aForm"
permanentForm _ aForm! !
!FacsBox methodsFor: 'accessing'!
acceptInput: aPoint
"default method for a box to get input, if it accepts input.
The point where the box was poked is supplied if needed."
| oldInput newInput |
oldInput _ self value.
oldInput isNil
ifTrue: [oldInput _ '']
ifFalse: [oldInput _ oldInput first].
newInput _ FillInTheBlank request: 'Enter Input for this Box' initialAnswer: oldInput printString.
^newInput!
links
| myLinks |
myLinks _ OrderedCollection new.
inputPorts notNil
ifTrue: [ inputPorts do:
[:each | each link notNil
ifTrue: [myLinks add: each link]]].
outputPort notNil
ifTrue: [outputPort do:
[:each | each link notNil
ifTrue: [myLinks add: each link]]].
^myLinks! !
!FacsBox methodsFor: 'port access'!
findInputPort: aPoint
"find and return an input port that can be linked to at
aPoint, OutputStateBox can accept an infinite number of incoming links"
| newPort result ports |
result _ self getInputPort: aPoint.
result isNil
ifTrue:
[ports _ inputPorts select: [:each | each boundingBox containsPoint: aPoint].
ports isEmpty
ifTrue: [^nil]
ifFalse:
[newPort _ (ports at: 1) shallowCopy.
newPort link: nil.
inputPorts add: newPort.
^newPort]]
ifFalse: [^result]!
findOutputPort: aPoint
"find and return an output port that can be linked to at
aPoint "
outputPort isNil ifTrue: [^nil].
outputPort do: [:each | each link isNil ifTrue: [^each]].
^nil!
getInputPort: aPoint
"find and return an input port that can be linked to at aPoint"
inputPorts isNil ifTrue: [^nil].
"see if user hit a port right on the nose. If so give it to him."
inputPorts do: [:each | ((each boundingBox containsPoint: aPoint)
and: [each link isNil])
ifTrue: [^each]].
"If no input port was hit, return first empty one."
inputPorts do: [:each | each link isNil ifTrue: [^each]].
"If none available ..."
^nil!
initInputPortsFromRectangles: rectangles
"initialize the input ports of the receiver"
inputPorts _ rectangles collect: [:each | (FacsInputPort new: each)
box: self]!
initOutputPortsFromRectangles: rectangles
"initialize the output ports of the receiver"
outputPort _ rectangles collect: [:each | (FacsOutputPort new: each)
box: self]! !
!FacsBox methodsFor: 'initialization'!
initializeAt: aPoint withName: aName withForm: aForm superManager: aManager
"initialize the new FoibleBox at aPoint with form aForm "
name isNil ifFalse: [^self error: 'Cannot reinitialize a ' , self class name].
name _ aName.
self permanentForm: aForm.
self offset: aPoint.
owner _ aManager!
initializePorts
"initialize the ports of the FoibleBox"
self inputs: 1 outputs: 2.! !
!FacsBox methodsFor: 'interface tests'!
acceptsDataLinks: aPoint
"Return whether I accept DataLinks
at the user interface"
| port |
port _ self findInputPort: aPoint.
^port isNil not!
canAcceptInput
"by default, boxes can't accept input"
^false!
givesDataLinks: aPoint
"Return whether I give DataLinks
at the user interface"
| port |
port _ self findOutputPort: aPoint.
^port isNil not! !
!FacsBox methodsFor: 'calculations'!
clearInputValues
"clear the input values from the ports"
inputPorts do: [:each | each clear]!
endOfInput
PopUpNotifier message: 'End of input string
String not accepted'.!
firstValue
"return the first value of the receiver"
^self value at: 1!
firstValue: aValue
"set the first value of the receiver"
self value at: 1 put: aValue!
getInputValues
"get the input values form the ports"
^inputPorts collect: [:each | each value]!
inActive
active _ false!
indicate
active _ true!
initValue: aValue
"give the receiver an initial value"
self value: aValue!
isActive
active isNil ifTrue: [active _ false].
^active!
outputResult: result
"send the result to all ouput ports"
self inActive.
(1 to: outputPort size)
do: [:i | (outputPort at: i)
token: result].!
token
"the sender, an input port, has received a new value for
the receiver"
| values result |
active notNil ifTrue: [values _ self getInputValues.
self clearInputValues.
values isNil ifTrue: [^nil].
result _ values detect: [:each | each isKindOf: OrderedCollection] ifNone: [^nil].
result isEmpty ifTrue: [self endOfInput.
^nil.].
self outputResult: result.]!
value
"return the value of the receiver"
^value!
value: aValue
"set the value of the receiver"
value _ aValue! !
!FacsBox methodsFor: 'displaying'!
displayBox
"returns boundingBox of the receiver if it displays its
value, nil otherwise"
^nil!
displayValue
"displays the receiver's current value"
^self subclassResponsibility! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
FacsBox class
instanceVariableNames: ''!
!FacsBox class methodsFor: 'form access'!
iconDirectory
"return the directory that contains the icons for the Facs"
^FacsDirectory iconDirectory! !
!FacsBox class methodsFor: 'displaying'!
asCursor
"return an image of the receiver which can be used as a cursor"
^self baseForm deepCopy! !
!FacsBox class methodsFor: 'instance creation'!
offset: aPoint withName: aString withForm: aForm superManager: aManager
"create aType FoibleBox at aPoint with form aForm"
| foibleBox |
foibleBox _ super new.
foibleBox initializeAt: aPoint withName: aString withForm: aForm superManager: aManager.
^foibleBox! !
FacsBox subclass: #StartState
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Facs'!
!StartState methodsFor: 'form access'!
addInput: aNumber toForm: aForm
"display aValue on aForm and return it"
"Write the number aNumber to aForm "
| aNumberString aDisplayText |
aNumberString _ aNumber printString.
aDisplayText _ aNumberString asDisplayText.
aDisplayText textStyle: (TextStyle styleNamed: #icon).
aDisplayText displayOn: aForm at: 4 @ 3.
^aForm!
inputForm
"return a copy of the receiver's form with the current input
displayed"
| aForm |
aForm _ self baseForm.
aForm offset: 0@0.
^self addInput: self value toForm: aForm! !
!StartState methodsFor: 'displaying'!
displayValue
"displays the receiver's current value"
self removeAllForms.
forms add: self inputForm! !
!StartState methodsFor: 'accessing'!
initValue: aValue
"store the receiver's initial value"
self value: aValue.
self displayValue!
newInputFromUser: aValue
"inform the receiver that he has new input from the user"
aValue size > 0
ifTrue:
[self value: aValue.
active _ true.
^self boundingBox]
ifFalse: [^'State input must be a string, please try again']!
value: aValue
"set the value of the receiver"
value _ aValue.
self displayValue! !
!StartState methodsFor: 'calculation'!
token
self outputResult: (value asOrderedCollection)! !
!StartState methodsFor: 'initialization'!
initializeAt: aPoint withName: aName withForm: aForm superManager: aManager
"initialize the new FoibleBox at aPoint"
super
initializeAt: aPoint
withName: aName
withForm: aForm
superManager: aManager.
self initValue: '0'! !
!StartState methodsFor: 'interface tests'!
canAcceptInput
"input boxes accept input by default"
^true! !
FacsBox subclass: #DeadState
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Facs'!
!DeadState methodsFor: 'initialization'!
initializePorts
"initialize the ports of the FoibleBox"
self inputs: 1 outputs: 0.! !
!DeadState methodsFor: 'output'!
indicate
PopUpNotifier message: 'DEAD STATE - Input not accepted'.! !
FacsBox subclass: #FinalState
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Facs'!
!FinalState methodsFor: 'output'!
endOfInput
PopUpNotifier message: 'End of input string
FINAL STATE - Input accepted'.! !
FacsBox subclass: #BinaryState
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Facs'!
Port subclass: #FacsOutputPort
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Facs'!
!FacsOutputPort methodsFor: 'calculations'!
token: aValue
"the receiver has a new value, pass the value to its link"
link isNil
ifFalse: [link token: aValue]! !
ToolBenchView subclass: #FacsView
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Facs'!
ToolBenchView comment:
'Finite state machine simulator written as a class project
using Foible for CS497 REJ, fall 1990, by
Kamal A. Khan <kkhan@suna0.cs.uiuc.edu>'!
!FacsView methodsFor: 'initialize'!
initializeWithModel: aFoibleProgram
"Add the two sub-views: 2 canvases (with a dummy form for now)"
| frontView |
self model: aFoibleProgram.
frontView _ CanvasView new.
frontView model: (aFoibleProgram firstManager).
self addSubView: frontView in: (0@0 extent: 1.0@1) borderWidth: 1.
canvas _ OrderedCollection with: frontView! !
!FacsView methodsFor: 'subview access'!
canvas
^canvas! !
!FacsView methodsFor: 'private'!
installCanvasTools
"tell my canvas what its Tools are"
(self canvas at: 1) addTools: (OrderedCollection new
add: StateTool new;
add: TransitionTool new;
add: EditTool new;
add: DataTool new;
add: StepTool new;
yourself)!
tools
"return an OrderdCollection of the icons for the palette"
^(OrderedCollection new
add: StateTool icon;
add: TransitionTool icon;
add: EditTool icon;
add: DataTool icon;
add: StepTool icon;
yourself)! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
FacsView class
instanceVariableNames: ''!
!FacsView class methodsFor: 'instance creation'!
open
"Create a new FacsManager and open a FacsView on it"
"FacsView open."
self openOn: ((FoibleProgram with: FacsManager new) name: 'FACS')!
openProgram
"Open an existing FacsView program saved as a binary"
"FacsView openProgram."
^super openProgram!
openProgram: aName
"Open an existing FacsView program saved as a binary"
"FacsView openProgram: <aName>. "
^super openProgram: aName! !
FoibleLink subclass: #FacsLink
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Facs'!
!FacsLink methodsFor: 'displaying'!
displayBox
"answers nil, indicating the receiver does not display its
value during calculations"
^nil! !
!FacsLink methodsFor: 'calculations'!
initValue: aValue
"ignore this message, it is for boxes only"
^self! !
!FacsLink methodsFor: 'interface tests'!
acceptsDataLinks: aPoint
"Return whether I accept DataLinks
at the user interface"
^false!
canAcceptInput
"just say no to input requests for wires"
^false!
canBeCopied
"do not copy links"
^false!
givesDataLinks: aPoint
"Return whether I give DataLinks
at the user interface"
^false! !
!FacsLink methodsFor: 'initialization'!
from: aSource to: aDest withPath: newPath
"Initialize this FoibleLink linked from aSource to
aDest, using the given newPath to make my form"
source isNil ifFalse: [self error: 'cannot re-initialize a ' , self class name].
source _ aSource.
source addLink: self.
destination _ aDest.
destination addLink: self.
self path: newPath! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
FacsLink class
instanceVariableNames: ''!
!FacsLink class methodsFor: 'form access'!
iconDirectory
"return the directory that contains the icons for Facs"
^FacsDirectory iconDirectory! !
FacsLink subclass: #ZeroLink
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Facs'!
!ZeroLink methodsFor: 'calculations'!
token: aValue
"the receiver has a new value, transmit only if proper type"
| symbol newValue |
aValue isEmpty ifTrue: [^nil].
newValue _ aValue shallowCopy.
symbol _ newValue removeFirst.
(symbol = $0)
ifTrue: [destination token: newValue.]
ifFalse: [^nil].! !
FacsLink subclass: #OneLink
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Facs'!
!OneLink methodsFor: 'calculations'!
token: aValue
"the receiver has a new value, transmit only if proper type"
| symbol newValue |
aValue isEmpty ifTrue: [^nil].
newValue _ aValue shallowCopy.
symbol _ (newValue removeFirst).
(symbol = $1)
ifTrue: [destination token: newValue.]
ifFalse: [^nil].! !
Port subclass: #FacsInputPort
instanceVariableNames: 'value '
classVariableNames: ''
poolDictionaries: ''
category: 'Facs'!
!FacsInputPort methodsFor: 'calculations'!
token: aValue
"the sender is passing a new value for use in the receiver's box; hold value and
notify box"
aValue isNil ifTrue: [box endOfInput]
ifFalse: [value _ aValue.
box indicate.]! !
!FacsInputPort methodsFor: 'accessing'!
clear
"clear the value of the receiver"
value _ nil!
value
"return the value of the receiver"
^value! !
FoibleManager subclass: #FacsManager
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Facs'!
!FacsManager methodsFor: 'activity'!
reset
"make all my boxes inactive"
boxes do: [:each | (each isKindOf: FacsBox)
ifTrue: [each inActive]].!
showActive: aView
"get list of active boxes"
| activeSet |
activeSet _ OrderedCollection new.
boxes do: [:each | ((each isKindOf: FacsBox) & (each isActive))
ifTrue: [activeSet add: each]].
^activeSet! !
!FacsManager methodsFor: 'adding'!
add: aClass at: aPoint
"add a Foible of the class aClass at aPoint"
^self addBox: [:name | aClass
offset: aPoint
withName: name
withForm: aClass asCursor
superManager: self]! !
!FacsManager methodsFor: 'displaying'!
displayBox
"returns the area of the manager's box that needs to be
redrawn during calculations"
| aBox aRectangle |
boxes do:
[:each |
aBox _ each displayBox.
aRectangle isNil
ifTrue: [aRectangle _ aBox]
ifFalse: [aBox isNil ifFalse: [aRectangle _ aRectangle merge: aBox]]].
^aRectangle! !
!FacsManager methodsFor: 'accessing'!
changeValue: name to: newInput
"Inform the Box with the given name that it has new input"
| box |
box _ self findName: name.
box isNil ifTrue: [^nil].
^box newInputFromUser: newInput!
lastBox
"returns the last box added to to the receiver"
^boxes last! !
Object subclass: #FacsDirectory
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Facs'!
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
FacsDirectory class
instanceVariableNames: ''!
!FacsDirectory class methodsFor: 'form access'!
iconDirectory
"return the directory that contains the icons for the Facs"
^'/Facs/icons'! !
Tool subclass: #FacsTool
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Facs'!
!FacsTool methodsFor: 'menu messages'!
add: aClass
"Get a point in the viewport and add a Foible of the class
aClass there"
| aPoint aThing currentModel aCursor |
currentModel _ model.
aCursor _ aClass asCursor.
aPoint _ self getThingPoint: aCursor.
aPoint isNil ifTrue: [^nil].
currentModel _ self getManager: aPoint.
currentModel isNil ifTrue: [^nil].
aThing _ currentModel addBox: [:name | aClass
offset: aPoint
withName: name
withForm: aCursor
superManager: currentModel].
model changed: aThing!
getManager: aPoint
"return the manager of the box at aPoint"
| aBox |
aBox _ model find: aPoint.
aBox isNil
ifTrue: [^model]
ifFalse: [^aBox manager]! !
!FacsTool methodsFor: 'accessing'!
getView
^view! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
FacsTool class
instanceVariableNames: ''!
!FacsTool class methodsFor: 'form access'!
iconDirectory
"return the directory that contains the icons for Facs"
^FacsDirectory iconDirectory! !
FacsTool subclass: #StepTool
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Facs'!
!StepTool methodsFor: 'menu messages'!
redButtonActivity
"red button activity for StepTool"
self step!
reset
"set all states inactive"
model reset!
step
"advance the state machine one step from a particular state"
| newPoint aThing displaySet |
newPoint _ self getPoint: self class cursor.
newPoint isNil ifTrue: [^nil]. "User aborted"
aThing _ model find: newPoint suchThat: [:it | it isKindOf: FacsBox].
aThing isNil ifTrue: [^nil].
aThing token.
displaySet _ model showActive: view.
displaySet isEmpty
ifTrue: [PopUpNotifier message: 'No valid transition
Input not accepted'.
self reset.]
ifFalse: [[Sensor redButtonPressed]
whileFalse: [displaySet do: [ :each | Display flash: (self getView
displayTransform: each boundingBox)]]].! !
!StepTool methodsFor: 'menu setup'!
installMenu
"Install our menu"
controller yellowButtonMenu: (PopUpMenu labels: 'Open Layout
Save Layout
Reset Automata')
yellowButtonMessages: #(open save reset)! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
StepTool class
instanceVariableNames: ''!
!StepTool class methodsFor: 'accessing'!
cursorOffset
" return the offset of my cursor "
^ -8 @ -8! !
FacsTool subclass: #TransitionTool
instanceVariableNames: 'transitionType '
classVariableNames: ''
poolDictionaries: ''
category: 'Facs'!
!TransitionTool methodsFor: 'menu setup'!
installMenu
"Install our menu"
controller yellowButtonMenu: (PopUpMenu labels: 'Zero-transition
One-transition')
yellowButtonMessages: #(zeroTransition oneTransition )! !
!TransitionTool methodsFor: 'menu messages'!
add
"link this type of link"
| fromThing toThing link aProtoLink lines |
aProtoLink _ self getPath.
aProtoLink isNil ifTrue: [^nil].
fromThing _ aProtoLink origin.
toThing _ aProtoLink destination.
lines _ aProtoLink lines.
link _fromThing box owner
addLink: transitionType
from: fromThing
to: toThing
withPath: lines.
link isNil ifTrue: [^nil].
model changed: link.!
getPath
"Allow the user to draw the path between the two boxes
(with no restrictions) and return the path"
^self
pathFrom: [:it :point | it givesDataLinks: point]
to: [:it :point | it acceptsDataLinks: point]
width: (self transition) width
both: [:a :b | a box = a box] "dummy test"!
oneTransition
"assigns the current transition type"
transitionType _ OneLink!
redButtonActivity
"red button activity for TransitionTool"
self add!
zeroTransition
"assigns the current transition type"
transitionType _ ZeroLink! !
!TransitionTool methodsFor: 'accessing'!
transition
transitionType isNil ifTrue:[transitionType _ ZeroLink].
^transitionType! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
TransitionTool class
instanceVariableNames: ''!
!TransitionTool class methodsFor: 'accessing'!
cursorOffset
"Return the offset of my cursor"
^-8 @ -8! !
FacsTool subclass: #StateTool
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Facs'!
!StateTool methodsFor: 'menu messages'!
binaryState
self add: BinaryState!
deadState
self add: DeadState!
finalState
self add: FinalState!
startState
self add: StartState! !
!StateTool methodsFor: 'menu setup'!
installMenu
"Install my menu"
controller yellowButtonMenu: (PopUpMenu labels: 'Start-State
Binary-State
Final-State
Dead-State' lines: #(4 ))
yellowButtonMessages: #(startState binaryState finalState deadState )! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
StateTool class
instanceVariableNames: ''!
!StateTool class methodsFor: 'accessing'!
cursorOffset
"Return the offset of my cursor"
^-8 @ -8! !
FacsTool subclass: #EditTool
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Facs'!
EditTool comment:
'EditTool is the concrete class for moving, deleting, and copying Boxes.'!
!EditTool methodsFor: 'menu messages'!
copy
"Find an object and copy it"
| oldThing newPoint newImage currentModel |
newPoint _ self getPoint: self class moverCursor.
currentModel _ model.
newPoint isNil ifTrue: [^nil].
"User aborted"
oldThing _ model find: newPoint suchThat: [:it | it canBeCopied].
oldThing isNil ifTrue: [^false].
Sensor cursorPoint: (view displayTransform: oldThing offset).
newImage _ oldThing class asCursor.
newPoint _ self getThingPoint: newImage.
newPoint isNil ifTrue: [^nil].
currentModel _ self getManager: newPoint.
currentModel isNil ifTrue: [^nil].
"The thing already exists, abort"
Cursor wait show.
oldThing _ currentModel addBox: [:name | oldThing class
offset: newPoint
withName: name
withForm: newImage
superManager: currentModel].
model changed: oldThing.
model cursor show.!
delete
"Find an object and remove it from list, return nil if not found"
| aPoint aThing aRectangle |
aPoint _ self getPoint: self class killCursor.
aPoint isNil ifTrue: [^nil].
"User aborted"
aThing _ model find: aPoint suchThat: [:it | it canBeDeleted].
aThing isNil ifTrue: [^nil].
"No such object"
(BinaryChoice message: 'Really delete' , aThing name , '?')
ifFalse: [^nil].
aRectangle _ aThing owner remove: aThing.
model changed: aRectangle.!
move
"Find an object and move it"
| oldThing newPoint aRectangle currentModel aBox |
newPoint _ self getPoint: self class cursor.
newPoint isNil ifTrue: [^nil]. "User aborted"
oldThing _ model find: newPoint suchThat: [:it | it canMoveIndependently].
oldThing isNil ifTrue: [^nil].
(oldThing isKindOf: self defaultLinkClass)
ifTrue: [aRectangle_self moveLine: oldThing
point: newPoint].
(oldThing isKindOf: FoibleBox)
ifTrue: [Sensor cursorPoint: (view displayTransform: oldThing offset).
newPoint _ self getThingPoint: oldThing ghostForm.
newPoint isNil ifTrue: [^nil].
currentModel _ model.
aBox _ model find: newPoint suchThat: [:it | it isKindOf: FoibleBox].
aBox notNil
ifTrue: [aBox = oldThing
ifTrue: [currentModel _ aBox owner]
ifFalse: [aBox manager notNil
ifTrue: [currentModel _ aBox manager]
ifFalse: [currentModel _ aBox owner]].
oldThing manager notNil
ifTrue: [(aBox inside: oldThing manager)
ifTrue: [currentModel _ oldThing owner]] ].
Cursor wait show.
aRectangle _ currentModel
moveBox: oldThing
byBlock: [:box | box offset: newPoint]].
aRectangle notNil
ifTrue: [model changed: aRectangle].
model cursor show!
redButtonActivity
self move! !
!EditTool methodsFor: 'menu setup'!
installMenu
"Install our menu"
controller yellowButtonMenu: (PopUpMenu labels: 'Delete state
Copy state')
yellowButtonMessages: #(delete copy )! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
EditTool class
instanceVariableNames: 'moverCursor killCursor '!
!EditTool class methodsFor: 'class initialization'!
initializeForms
" send this class method when the form for my icon or cursor has been changed "
" <class name> initializeForms "
icon _ self getIcon.
killCursor _ (self getCursor: 'Kill.cur') offset: -8@-8.
moverCursor _ (self getCursor: 'Mover.cur') offset: -7@-7.
toolCursor _ self getCursor offset: self cursorOffset.! !
!EditTool class methodsFor: 'accessing'!
cursorOffset
"Return the offset of my cursor"
^ -8 @ -8!
killCursor
killCursor isNil ifTrue: [killCursor _ (self getCursor: 'Kill.cur') offset: -8@-8].
^killCursor!
moverCursor
moverCursor isNil ifTrue: [moverCursor _ (self getCursor: 'Mover.cur') offset: -8@-8].
^moverCursor! !
FacsTool subclass: #DataTool
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'Facs'!
!DataTool methodsFor: 'private'!
getPoint: aCursor
"Get a point in the viewport and return its value, nil if left the viewport"
| aPoint |
aCursor show.
[ Sensor noButtonPressed & controller isControlActive ]
whileTrue: [aPoint _ Sensor cursorPoint].
model cursor show.
controller isControlActive ifFalse: [^nil].
^(view inverseDisplayTransform: (Sensor waitButton)) rounded! !
!DataTool methodsFor: 'menu messages'!
change
"give new input to the given FoibleBox"
| aThing aPoint aRectangle newModel thingName newInput |
aPoint _ self getPoint: Cursor currentCursor.
aPoint isNil ifTrue: [^nil].
aThing _ model find: aPoint.
aThing isNil ifTrue: [^nil].
newModel _ aThing owner.
thingName _ aThing name.
aThing canAcceptInput
ifTrue:
[newInput _ aThing acceptInput: aPoint - aThing offset.
aRectangle _ newModel changeValue: thingName to: newInput.
aRectangle class == String
ifTrue: [PopUpNotifier message: aRectangle]
ifFalse:
[model changed: #value with: aRectangle]]!
redButtonActivity
"red button activity for WiringLinkTool"
self change! !
!DataTool methodsFor: 'menu setup'!
installMenu "install our menu"
controller yellowButtonMenu: nil
yellowButtonMessages: nil! !
"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!
DataTool class
instanceVariableNames: ''!
!DataTool class methodsFor: 'accessing'!
cursorOffset
" return the offset of my cursor "
^ -8 @ -8! !